<?php
function getLoginForm(){
    global $form; 
    $ret="<div class=\"header_02\">User Login</div>
        <div class='news_section'>";
    if($form->num_errors > 0){
        $ret.= "
            <font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found </font>";
    }
    $ret.="<div id='login_box'>
        <form action=\"process.php\" method=\"POST\">
        <p><label for='user'>Username:</label><input type=\"text\" name=\"user\" maxlength=\"50\" value=\"{$form->value('user')}\">{$form->error('user')}
        <p><label for='pass'>Password:</label><input type=\"password\" name=\"pass\" maxlength=\"30\" value=\"{$form->value('pass')}\"> {$form->error('pass')}
        <p> <a href='?page=forgotpass'>
        Forgot your  Password ?</a>
        &nbsp; &nbsp; &nbsp;
    <input type=\"hidden\" name=\"synlogin\" value=\"1\">
        <input id='inputsubmit1' type=\"submit\" value=\"Login\">
        </form>
        </div>
        </div>
        <div class='cleaner'> </div>
        ";
    return $ret;
}
function getUserMenu(){
    global $user;
    $ret;
    if($user->logged_in && $user->level>0){
        $ret.="<ul><li class='newbullet'><a href='?page=changepass'>Account</a></li>";
        if($user->level == MR_LEVEL || $user->level==MMR_LEVEL){
        $ret.=" <li class='newbullet'><a href='?page=addtada'>Add TA/DA</a></li>
            <li class='newbullet'><a href='?page=viewtada'>View TA/DA</a></li>
            <li class='newbullet'><a href='?page=adddcr'>Add DCR</a></li>
            <li class='newbullet'><a href='?page=viewdcr'>View DCR</a></li>
            <li class='newbullet'><a href='?page=addpartystock'>Add Party Stock</a></li>
            <li class='newbullet'><a href='?page=viewpartystock'>View Party Stock</a></li>";
        }
        if($user->level==MMR_LEVEL || $user->level==ADMIN_LEVEL){
            $ret.="<li class='newbullet'><a href='?page=mviewdcr'>Mgr. View DCR</a></li>
            <li class='newbullet'><a href='?page=mviewtada'>Mgr. View TA/DA</a></li>
            <li class='newbullet'><a href='?page=mviewpartystock'>Mgr. View Party Stock</a></li>";
        }

        if($user->level==SK_LEVEL || $user->level==ADMIN_LEVEL){
            $ret.="<li class='newbullet'><a href='?page=addmaterial'>Add Material</a></li>
            <li class='newbullet'><a href='?page=viewmaterial'>View Material</a></li>
            <li class='newbullet'><a href='?page=addstock'>Add Stock</a></li>
            <li class='newbullet'><a href='?page=vstock'>View Stock</a></li>";
        }
            
        if($user->isAdmin()){
            $ret.="<li class='newbullet'><a href='?page=addtasetting'>Add TA Setting</a></li>"
                ."<li class='newbullet'><a href='?page=viewtasetting'>View TA Setting</a></li>"
                ."<li class='newbullet'><a href='?page=addparty'>Add Party</a></li>"
                ."<li class='newbullet'><a href='?page=viewparty'>View Party</a></li>"
                ."<li class='newbullet'><a href='?page=addproduct'>Add Product</a></li>"
                ."<li class='newbullet'><a href='?page=viewproduct'>View Product</a></li>"
                ."<li class='newbullet'><a href='?page=adduser'>Add User</a></li>"
                ."<li class='newbullet'><a href='?page=userlist'>Team</a></li>";
        }
        $ret.="<li class='newbullet'><a href=\"process.php\">Logout</a></li>
            </ul>";
    }
    return $ret;
}
function getGreetings(){
    global $user;
    $ret= "Welcome<b> $user->username </b>";
    return $ret;
}
function getNews(){
global $database;
$newslist=$database->getNews();
$str="<div class='header_02'>News and Events</div>";
foreach ($newslist as $news){
    $day= explode('_',$news['date']);
    $str.="<div class='news_section'>
                <div class='news_date'>
                        $day[1]<span> $day[0]</span>
                </div>
                <div class='news_content'>
                    <div class='header_05'>
                        <a href='#'>{$news['title']}</a>
                    </div>
                    <p>{$news['body']}</p>
                </div>
                <div class='cleaner'></div>
                </div>";
}
$str.="</div>";
return $str;
}
?>
